/*
 * bubbleChart.fx
 *
 * Created on 23-dic-2009, 16:04:55
 */

package ProgramSamples.Graphics;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.stage.Alert;
import javafx.scene.paint.Color;
import javafx.scene.chart.*;
import javafx.scene.chart.part.*;


def bubbleData1: BubbleChart.Series = BubbleChart.Series {
    name: "1996"
    fill: Color.web("#ff5904")
    data: [
	    BubbleChart.Data { xValue:30 yValue:35 radius:116 /* toolTip:"Mango" */  action:function(){Alert.inform("Clicked on Mango")} },
		BubbleChart.Data { xValue:42 yValue:60 radius:99 /* toolTip:"Apple" */   action:function(){Alert.inform("Clicked on Apple")} },
		BubbleChart.Data { xValue:8 yValue:15 radius:33 /* toolTip:"Orange" */   action:function(){Alert.inform("Clicked on Orange")} },
		BubbleChart.Data { xValue:22 yValue:30 radius:72 /* toolTip:"Strawberry" */  action:function(){Alert.inform("Clicked on Strawberry")} },
		BubbleChart.Data { xValue:18 yValue:20 radius:55 /* toolTip:"Kiwi" */ },
		BubbleChart.Data { xValue:25 yValue:41 radius:58 /* toolTip:"Tomato" */ },
		BubbleChart.Data { xValue:12 yValue:17 radius:80 /* toolTip:"Cucumber" */ },
		BubbleChart.Data { xValue:20 yValue:30 radius:105 /* toolTip:"Potato" */ }
	]
}

def bubbleData2: BubbleChart.Series = BubbleChart.Series {
    name: "1997"
    fill: Color.web("#4371AB")
    data: [
		BubbleChart.Data { xValue:14 yValue:35 radius:116 /* toolTip:"Mango" */  action:function(){Alert.inform("Clicked on Mango")} },
		BubbleChart.Data { xValue:22 yValue:20 radius:99 /* toolTip:"Apple" */  action:function(){Alert.inform("Clicked on Apple")} },
		BubbleChart.Data { xValue:28 yValue:25 radius:33 /* toolTip:"Orange" */  action:function(){Alert.inform("Clicked on Orange")} },
		BubbleChart.Data { xValue:32 yValue:20 radius:72 /* toolTip:"Strawberry" */ },
		BubbleChart.Data { xValue:38 yValue:20 radius:55 /* toolTip:"Kiwi" */ },
		BubbleChart.Data { xValue:5 yValue:21 radius:58 /* toolTip:"Tomato" */ },
		BubbleChart.Data { xValue:2 yValue:27 radius:80 /* toolTip:"Cucumber" */ },
		BubbleChart.Data { xValue:12 yValue:20 radius:105 /* toolTip:"Potato" */ }
	]
}


def bubbleChart = BubbleChart {
    title: "Bubble Chart"
    data: [bubbleData1, bubbleData2]
    radiusScale: 0.07
    xAxis: NumberAxis {
        label: "Price (Bt./kg.)"
        lowerBound: -5
        upperBound: 50
        tickUnit: 5
        formatTickLabel: function(value):String { "{(value as Float) as Integer}" }
    }
    yAxis: NumberAxis {
        label: "Original Cost (Bt./kg.)"
        lowerBound: 0
        upperBound: 70
        tickUnit: 10
        formatTickLabel: function(value):String { "{(value as Float) as Integer}" }
    }
}

Stage {
    title: "Bubble Chart"
    scene: Scene{
	    width: 540
            height: 410
            content: bubbleChart
     } //Scene
}//Stage